/*获取订单号*/
var maintainOrderId = sessionStorage.getItem("maintainOrderId");
var maintain_id = sessionStorage.getItem("maintainId");
var loginData = JSON.parse(web.readCookie("loginData"));
var repair_method = 0;
var datas = {};
var maintaintype = 0;
var warehouseId ; //订单发货仓id
var provinceName,cityName,areaName,streetName,detailAddressName,receiverName,receiverPhone;
$('#typeChangeSave').hide();
$('#typeChangeCancel').hide();
/*通过订单号获取订单详情*/
$.ajax({
    type: "POST",
    url: root.orderInter.order_queryMaintainOrderDetails,
    cache: false,  //禁用缓存
    dataType: "json",
    data: {
        order_id: maintainOrderId,// 订单编号
        maintain_id: maintain_id,// 订单编号
    },
    success: function (result) {
        var orderRefundMaintain = result.orderRefundMaintain;
        console.log(orderRefundMaintain)
        console.log(result)
        warehouseId = result.parent_warehouse_id;
        provinceName = orderRefundMaintain.province_name;
        cityName = orderRefundMaintain.city_name;
        areaName = orderRefundMaintain.area_name;
        streetName = orderRefundMaintain.street_name||'';
        detailAddressName = orderRefundMaintain.detail_address;
        receiverName = orderRefundMaintain.received_name;
        receiverPhone = orderRefundMaintain.received_telephone;
        var maintaitype=""
        if(result.orderRefundMaintain.maintain_type==10){
            maintaitype="客户自行送维修点"
        }else if(result.orderRefundMaintain.maintain_type==20){
            maintaitype="厂家上门维修"
        }
        else if(result.orderRefundMaintain.maintain_type==30){
            maintaitype="鑫方盛售后上门维修"
        }
        $('#repair-type').html(maintaitype);
        $('#repair-type').val(result.orderRefundMaintain.maintain_type);
        $('#addressDetail').val(detailAddressName);
        $('#receiveArea').val(provinceName+cityName+areaName);
        $('#receiverName').val(receiverName);
        $('#receiverPhone').val(receiverPhone);
        renderOrderPage(result);
        sessionStorage.setItem("maintainOrderDetail",JSON.stringify(result));
    },
    error: function (XMLHttpRequest, textStatus, errorThrown) {
        alert(XMLHttpRequest);
    }
});
var maintainOrderDetail = JSON.parse(sessionStorage.getItem("maintainOrderDetail"));

function detailCancel() {
    layer_show("取消订单","maintainCancleAlert.html","600","300");
}
function rejectCheck() {
    layer_show("审核驳回","maintainRemark.html","600","300");
}
function passCheck() {
    console.log(root.orderInter)
    layer.confirm('审核通过？',function(index){
        $.ajax({
            contentType: "application/json",
            type: "POST",
            url: root.orderInter.order_maintainunaudit_auditAgree,
            cache: false,  //禁用缓存
            dataType: "json",
            data: JSON.stringify({
                maintain_id: maintain_id,
                // audit_person_id: '12',
                // audit_person_name: '克服克服',
                operate_userid: loginData.user.user_ID,
                operate_username: loginData.user.name,
                maintain_remark: "没问题"
            }),  //传入组装的参数
            success: function (result) {
                console.log(result);
                layer.msg('审核成功',{icon: 6,time:1000},function () {
                    window.location.reload();
                });
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(XMLHttpRequest);
            }
        });
        layer.msg('已审核', {icon: 6,time:1000});
    });
}
function confirmComplete(){
    layer_show("确认完成","maintainComplete.html","600","300");
}

function changeOrderState(orderState) {
    $("#affirmMoney").siblings().css({
        display: "none"
    });
    switch (orderState){
        /*订单状态*/
        case 10:
            $("#passCheck").css({
                display: "inline"
            });
            $("#rejectCheck").css({
                display: "inline"
            });
            $('#confirmInfo').css({
                display: "none"
            });
            return "待审核";
            break;
        // case 20:
        //     $("#detailCancel").css({
        //         display: "inline"
        //     });
        //     return "已受理";
        //     break;
        case 30:
            $('#confirmComplete').css({
                display: "inline"
            });
            $('#detailCancel').css({
                display: "inline"
            });
            $('#confirmInfo').css({
                display: "block"
            });
            return "维修处理";
            break;
        case 50:
            $('#typeChange').css({
                display: "none"
            });

            $('#receiveArea').attr("disabled",true);
            $('#addressDetail').attr("disabled",true);
            $('#receiverName').attr("disabled",true);
            $('#receiverPhone').attr("disabled",true);

            return "已完成";
            break;
        case 60:
            $('#typeChange').css({
            display: "none"
            });

            $('#receiveArea').attr("disabled",true);
            $('#addressDetail').attr("disabled",true);
            $('#receiverPhone').attr("disabled",true);
            $('#receiverName').attr("disabled",true);
            return "已关闭";
            break;
    }
}
/*datatable*/
var dataSource = new Array();
//table的数据源
var table;   //table对象
dataSource = [];
function renderOrderPage(data) {
    datas = data;
    /*商品总金额计算*/
    // var goodsAmount = 0;
    // for(var i=0;i<data.listOrderItems.length;i++){
    //     goodsAmount += Number(data.listOrderItems[i].sale_price) * Number(data.listOrderItems[i].buyyer_count);
    // }
    // $("#goodsAmount").html(goodsAmount.toFixed(2));
    // $("#fare").html(data.orderBase.shipping_fee);
    // $("#orderAmount").html((goodsAmount+data.orderBase.shipping_fee).toFixed(2));
    // /*转换状态*/
    var order_status = changeOrderState(data.orderRefundMaintain.maintain_status);
    console.log(data.orderRefundMaintain.maintain_status)
    switch (data.orderRefundMaintain.maintain_status){
        /*订单状态*/
        case 10:
            $("#passCheck").css({
                display: "inline"
            });
            $("#rejectCheck").css({
                display: "inline"
            });
            $('#confirmInfo').css({
                display: "none"
            });
            // return "待审核";
            break;
        case 30:
            $('#confirmComplete').css({
                display: "inline"
            });
            $('#detailCancel').css({
                display: "inline"
            });
            $('#confirmInfo').css({
                display: "block"
            });
            // return "维修处理";
            break;
        case 50:
            $('#typeChange').css({
                display: "none"
            });
            // return "已完成";
            break;
        case 60:
            $('#typeChange').css({
                display: "none"
            });
            // return "已关闭";
            break;
    }
    $("#orderState").html(order_status);
    // $("#orderId").html(data.orderBase.order_id);
    // $("#creatOrderTime").html(data.orderBase.created_at);
    // if(data.orderBase.order_status == 10 || data.orderBase.order_status == 50){
    //     $(".orderRemark").css({
    //         display: "none"
    //     })
    // }
    //备注反显
    // $("#remark").val(data.orderMaintainRemark.maintain_remark);
    /*基本信息*/
    $("#askFor-code").html(data.orderRefundMaintain.maintain_id);
    $("#order-code").html(data.orderRefundMaintain.order_id);
    $("#sales-manager").html(data.orderRefundMaintain.sales_manager_name);
    /*关闭信息*/
    $("#close-time").html(data.listOrderRefundMaintainRemark.close_time);
    $("#operator").html(data.orderRefundMaintain.audit_person_name);
    $("#close-reason").html(data.orderRefundMaintain.close_reason);
    $("#close-intordoce").html(data.orderRefundMaintain.close_desc);
    /*审核信息*/
    for(var i in data.listOrderRefundMaintainRemark){
        if(data.listOrderRefundMaintainRemark[i].operate_type==10)      //审核操作信息
        {
            $('#audit-time').html(data.listOrderRefundMaintainRemark[i].created_at);
            $('#auditor').html(data.listOrderRefundMaintainRemark[i].operate_username);
            $('#audit-desc').html(data.listOrderRefundMaintainRemark[i].maintian_remark);
        }
        else if(data.listOrderRefundMaintainRemark[i].operate_type==20)  /*审核驳回信息*/
        {
            $('#check').html('审核驳回信息');
            $('#audit-time').html(data.listOrderRefundMaintainRemark[i].created_at);
            $('#auditor').html(data.listOrderRefundMaintainRemark[i].operate_username);
            $('#audit-desc').html(data.listOrderRefundMaintainRemark[i].maintian_remark);
        }
        if(data.listOrderRefundMaintainRemark[i].operate_type==30)  /*已受理取消信息*/
        {
            $('#close-time').html(data.listOrderRefundMaintainRemark[i].created_at);
            $('#operator').html(data.listOrderRefundMaintainRemark[i].operate_username);
            $('#close-intordoce').html(data.listOrderRefundMaintainRemark[i].maintian_remark);
        }
        if(data.listOrderRefundMaintainRemark[i].operate_type==40)  /*退货处理取消*/
        {
            $('#close-time').html(data.listOrderRefundMaintainRemark[i].created_at);
            $('#operator').html(data.listOrderRefundMaintainRemark[i].operate_username);
            $('#close-intordoce').html(data.listOrderRefundMaintainRemark[i].maintian_remark);
        }
        if(data.listOrderRefundMaintainRemark[i].operate_type==50)  /*退款处理取消*/
        {
            $('#close-time').html(data.listOrderRefundMaintainRemark[i].created_at);
            $('#operator').html(data.listOrderRefundMaintainRemark[i].operate_username);
            $('#close-intordoce').html(data.listOrderRefundMaintainRemark[i].maintian_remark);
        }

    }
    /*维修申请信息*/
    if(data.orderRefundMaintain.maintain_reason==10){
        $("#maintain-reason").html('电机/主机不转、功率不够');
    }
    else if(data.orderRefundMaintain.maintain_reason==20){
        $("#maintain-reason").html('机器劲小、钻不动孔');
    }
    else if(data.orderRefundMaintain.maintain_reason==30){
        $("#maintain-reason").html('调速功能有问题');
    }
    else if(data.orderRefundMaintain.maintain_reason==40){
        $("#maintain-reason").html('开关坏');
    }
    else if(data.orderRefundMaintain.maintain_reason==50){
        $("#maintain-reason").html('电源问题');
    }
    else if(data.orderRefundMaintain.maintain_reason==60){
        $("#maintain-reason").html('机器不发动');
    }
    else if(data.orderRefundMaintain.maintain_reason==70){
        $("#maintain-reason").html('外机破损');
    }
    else if(data.orderRefundMaintain.maintain_reason==80){
        $("#maintain-reason").html('商品质量问题');
    }

    repair_method = data.orderRefundMaintain.repair_method;
    if(repair_method==10){
        $("#repair-type").html('鑫方盛维修');
    }
    else if(repair_method==20){
        $("#repair-type").html('代理公司维修');
    }
    $("#maintain-Info").html(data.orderRefundMaintain.maintain_desc);
    /*if(data.orderRefundMaintain.take_goods_type==10){
        $("#get-goods-type").html('客户邮寄');
    }
    else{
        $("#get-goods-type").html('上门取货');
    }*/
    $("#askFor-time").html(data.orderRefundMaintain.created_at);
    $("#askFor-operator").html(data.orderRefundMaintain.customer_name);


    /*if(data.orderRefundMaintain.maintain_type==10){
        $('#repair-type').html('客户自行送维修点');
        $('#addressDetail').val(detailAddressName);
        $('#receiveArea').val(provinceName+cityName+areaName);
        $('#receiverName').val(receiverName);
        $('#receiverPhone').val(receiverPhone);
        $('#receiveArea').attr("disabled",true);
        $('#addressDetail').attr("disabled",true);
        $('#receiverName').attr("disabled",true);
        $('#receiverPhone').attr("disabled",true);
    }
    else if(data.orderRefundMaintain.maintain_type==20){
        $('#repair-type').html('厂家上门维修');
        $('#addressDetail').val('');
        $('#receiveArea').val('');
        $('#receiverName').val('');
        $('#receiverPhone').val('');
    }
    else if(data.orderRefundMaintain.maintain_type==30){
        $('#repair-type').html('鑫方盛售后上门维修');
        $('#addressDetail').val('');
        $('#receiveArea').val('');
        $('#receiverName').val('');
        $('#receiverPhone').val('');
    }*/
    if(data.orderRefundMaintain.maintain_type==10){

        var returngoods  =JSON.parse(sessionStorage.getItem("returngoods"))
        var getGoodsAddress=""//取货地址
        var received_name=""//联系人
        var received_telephone=""//联系人电话号
        var addressDetail=""
        $.each(returngoods.data,function(k,s){
            if(datas.orderRefundMaintain.warehouse_id==s.warehouseId){
                getGoodsAddress=s.provinceName+""+s.cityName+""+districtName
                addressDetail=s.detailAddress
                received_name=s.contactPerson
                received_telephone=s.contactPhone
            }
        })

    } else if(data.orderRefundMaintain.maintain_type==20){
        $('#repair-type').html('厂家上门维修');
        $('#addressDetail').val(detailAddressName);
        $('#receiveArea').val(provinceName+cityName+areaName);
        $('#receiverName').val(receiverName);
        $('#receiverPhone').val(receiverPhone);
    } else if(data.orderRefundMaintain.maintain_type==30){
        $('#repair-type').html('鑫方盛售后上门维修');
        $('#addressDetail').val(detailAddressName);
        $('#receiveArea').val(provinceName+cityName+areaName);
        $('#receiverName').val(receiverName);
        $('#receiverPhone').val(receiverPhone);
    }

    /*if(data.orderRefundMaintain.maintain_type==30){
        $('#repair-type').html('鑫方盛售后上门维修');
        $('#addressDetail').val('');
        $('#receiveArea').val('北京市大兴区六环外');
        $('#receiverName').val('');
        $('#receiverPhone').val('');
    }

    if(data.orderRefundMaintain.maintain_type==10){
        if(data.orderRefundMaintain.warehouse_id==1){
            $('#repair-type').html('客户自行送维修点');
            $('#addressDetail').val("");
            $('#receiveArea').val("北京市 大兴区 大兴郊区");
            $('#receiverName').val("");
            $('#receiverPhone').val("");
        }else if(data.orderRefundMaintain.warehouse_id==2){
            $('#repair-type').html('客户自行送维修点');
            $('#addressDetail').val("工业区8号路111号天津鑫方盛五金交电有限公司");
            $('#receiveArea').val("天津 津南区 小站镇");
            $('#receiverName').val("李盖");
            $('#receiverPhone').val("15900287717");
        }else if(data.orderRefundMaintain.warehouse_id==4){
            $('#repair-type').html('客户自行送维修点');
            $('#addressDetail').val("龙湖镇富源路1号河南鑫方盛电子商务有限公司");
            $('#receiveArea').val("河南 郑州 新郑市");
            $('#receiverName').val("王建民");
            $('#receiverPhone').val("15001338015");
        }
    }
    if(data.orderRefundMaintain.maintain_type==20) {
        $('#repair-type').html('厂家上门维修');
        $('#addressDetail').val(detailAddressName);
        $('#receiveArea').val(provinceName+cityName+areaName);
        $('#receiverName').val(receiverName);
        $('#receiverPhone').val(receiverPhone);
        $('#receiveArea').attr("disabled",true);
        $('#addressDetail').attr("disabled",true);
        $('#receiverName').attr("disabled",true);
        $('#receiverPhone').attr("disabled",true);
    }*/
    /*for(var i in data.listOrderRefundMaintainRemark){
        if(data.listOrderRefundMaintainRemark[i].operate_type==20){

        }
        if(data.listOrderRefundMaintainRemark[i].operate_type==20){

        }
    }*/
    /*凭证信息*/
    for(var i in data.maintainProofList)
    {if(data.maintainProofList[i].pic_url!=''){
        $('#proofPics').append(' <img src="'+data.maintainProofList[i].pic_url+'" style="width:100px;height:100px"' +
            ' onclick="setSize(this)"' +
            ' title="点击放大">')
    }
    }
    /*商品信息*/
    dataSource.splice(0, dataSource.length);//清空数组
    $.each(data.listBaseAndMaintain, function (i, field) {
        var rowData = new Array();
        rowData.push(field.product_pic);
        rowData.push(field.warehouse_id);
        rowData.push(field.buyyer_count);
        rowData.push(field.delivery_count);
        rowData.push(field.receive_count);
        rowData.push(field.maintain_count);
        rowData.push(field.sku_code);
        rowData.push(field.product_name);
        rowData.push(field.sku_info);
        rowData.push(field.unit_name);
        rowData.push(field.sku_id);
        rowData.push(field.unit_name);// 计量单位
        rowData.push(field.color);
        dataSource.push(rowData);
    });
    initDataTable(dataSource);

    function initDataTable(dataSource) {
        var dttable = $('#datatable').dataTable(); // 初始化dataTable，清空上一个值
        dttable.fnClearTable(); //清空一下table
        dttable.fnDestroy(); //还原初始化了的datatable
        $("#datatable").DataTable({
            "autoWidth": false,
            "ordering": true,
            "searching": true,
            "paging": true,
            "retrieve": true,
            "destroy": true,
            "bAutoWidth": true,
            "bLengthChange": true,
            "aLengthMenu": [5, 10, 25, 50],
            "oLanguage": {
                "sLengthMenu": "每页显示 _MENU_ 条记录",
                "sZeroRecords": "抱歉， 没有找到",
                "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
                "sInfoEmpty": "没有数据",
                "sInfoFiltered": "(从 _MAX_ 条数据中检索)",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "前一页",
                    "sNext": "后一页",
                    "sLast": "尾页"
                },
                "sZeroRecords": "没有检索到数据",
                "sProcessing": "<img src='./loading.gif' />"
            },
            data: dataSource,
            columnDefs: [
                {
                    "visible": true,
                    "targets": 0
                },
                {
                    "render": function (data, type, row) {
                        var val = '<div onclick="goToGoodsDetail(\'Code详情\',\'../../goods/sku-info.html\',\''+row[10]+'\')" style="cursor:pointer;"><img style="float: left;height:55px;width:55px;padding-top: 5px;margin-left: 10px;" name="" src="'+ row[0] +'" alt=""><div style="float: left;width:180px;"><div>'+ row[6] +'</div><div>'+ row[7] +'</div><div>'+ row[12] +'</div><div>'+ row[8] +'</div></div></div>';
                        return val;
                    },
                    "targets": 0
                },
                {
                    "render": function (data, type, row) {
                        var warehouses=JSON.parse(sessionStorage.getItem("warehouses"))
                        var ss=""
                        $.each(warehouses.data,function(k,s){
                            if(row[1]==s.warehouseCode){
                                ss=s.warehouseName
                            }
                        })
                        var val = '<span>' + ss + '</span>';
                        return val;
                    },
                    "targets": 1
                },
                   {
                       "render": function (data, type, row) {
                           if(row[9]!=null){
                               var val = '<span>'+row[2]+ ''+row[9]+'</span>';
                               return val;
                           }
                          else{
                               var val = '<span>'+row[2]+ '</span>';
                               return val;
                           }
                       },
                       "targets": 2
                   },
                   {
                       "render": function (data, type, row) {
                           if(row[9]!=null){
                               var val = '<span>'+row[3]+ ''+row[9]+'</span>';
                               return val;
                           }
                           else{
                               var val = '<span>'+row[3]+ '</span>';
                               return val;
                           }
                       },
                       "targets": 3
                   },
                   {
                       "render": function (data, type, row) {
                           if(row[9]!=null){
                               var val = '<span>'+row[4]+ ''+row[9]+'</span>';
                               return val;
                           }
                           else{
                               var val = '<span>'+row[4]+ '</span>';
                               return val;
                           }
                       },
                       "targets": 4
                   },
                {
                    "render": function (data, type, row) {
                        if(row[9]!=null){
                            var val = '<span>'+row[5]+ ''+row[9]+'</span>';
                            return val;
                        }
                        else{
                            var val = '<span>'+row[5]+ '</span>';
                            return val;
                        }
                    },
                    "targets": 5
                }
            ]
        });
    };
}
/*改变图片大小*/
function setSize(img){
    var width = img.offsetWidth;
    console.log(width)
    if(width==100)
    {
        console.log(1)
        img.style.width=300+'px';
        img.style.height=300+'px';
    }
    else
    {
        console.log(2)
        img.style.width=100+'px';
        img.style.height=100+'px';
    }
}

/*改变送修方式*/
var fre =0;
var fangshi1;
var quyu;
var dizhi;
var dianhua;
$('#typeChange').click(function(){
    $('#repairType').css({
        display: "block"
    })
    fre=1;
    if(fre==1){
        console.log(1)
        var oDiv = document.getElementById("repairType");//假设HTML中div的id="repairType"
        $("#repair-type").click(function(){
            console.log(123)
            console.log(oDiv)
            if (oDiv.style.display == "none") {
                oDiv.style.display = "block";
            } else {
                oDiv.style.display = "none";
            }
        })
    }

    $(this).hide();
    $('#typeChangeSave').show();
    $('#typeChangeCancel').show();

    fangshi1=document.getElementById("repair-type").innerText;
    quyu=document.getElementById("receiveArea").value;  //收货区域
    dizhi=document.getElementById("addressDetail").value;  //详细地址
    name1=document.getElementById("receiverName").value;  // 收货人名称
    dianhua=document.getElementById("receiverPhone").value;  //收货人电话
})





// console.log($('#repair-type').html())///送修方式

$('#typeChangeCancel').click(function(){
    $('#repairType').css({
        display: "none"
    })
    $('#repair-type').click(function(){
        $('#repairType').css({
            display: "none"
        })
    })
    $(this).hide();
    $('#typeChange').show();
    $('#typeChangeSave').hide();
    $('#typeChangeCancel').hide();
    /////////////////////////取消  数据还原
    $('#repair-type').html(fangshi1);
    $('#receiveArea').val(quyu);
    $('#addressDetail').val(dizhi);
    $('#receiverName').val(name1);
    $('#receiverPhone').val(dianhua);
if(fangshi1=='客户自行送维修点')
{console.log(10);
    $('#receiveArea').attr("disabled",true);
    $('#addressDetail').attr("disabled",true);
    $('#receiverName').attr("disabled",true);
    $('#receiverPhone').attr("disabled",true);
}else
    {
        $('#receiveArea').attr("disabled",false);
        $('#addressDetail').attr("disabled",false);
        $('#receiverName').attr("disabled",false);
        $('#receiverPhone').attr("disabled",false);
    }
    //取消后关闭点击显示与隐藏
    fre=0;
    if(fre==0){
        console.log(1)
        var oDiv = document.getElementById("repairType");//假设HTML中div的id="repairType"
        $("#repair-type").click(function(){
                oDiv.style.display = "none";
        })
    }
    /////////////////

})

/*保存送修方式*/
$('#typeChangeSave').click(function(){
    //保存后关闭点击显示与隐藏
    fre=0;
    if(fre==0){
        console.log(1)
        var oDiv = document.getElementById("repairType");//假设HTML中div的id="repairType"
        $("#repair-type").click(function(){
            oDiv.style.display = "none";
        })
    }
    /////////
        if($('#addressDetail').val()==''||$('#receiverName').val()==''||$('#receiverPhone').val()=='')
        {
            $.Huimodalalert("请输入收货人信息",1500)
        }
    else {
        $.ajax({
            type: "POST",
            url: root.orderInter.order_changeMaintainType,
            cache: false,  //禁用缓存
            dataType: "json",
            contentType: "application/json",
            data: JSON.stringify({
                /*必传*/
                maintain_id: maintain_id,// 订单编号
                maintain_type: maintaintype,//送修方式
                received_name: $('#receiverName').val(),//收货人姓名
                received_telephone: $('#receiverPhone').val(),//收货人联系方式
                detail_address: $('#addressDetail').val()
            }),
            success: function (result) {
                console.log(result);
                $('#typeChange').show();
                $('#typeChangeSave').hide();
                $('#repairType').css({
                    display: "none"
                })
                $('#typeChangeCancel').hide();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(XMLHttpRequest);
            }

        });
    }
})
$('#repairType li').click(function(){
    var type = $(this).html();
    $('#repair-type').html(type);
    $('#repairType').css({
        display: "none"
    });
    maintaintype=$(this).val();
    if($(this).val()==10){
        var returngoods  =JSON.parse(sessionStorage.getItem("returngoods"))
        var getGoodsAddress=""//取货地址
        var received_name=""//联系人
        var received_telephone=""//联系人电话号
        var addressDetail=""
        $.each(returngoods.data,function(k,s){
            if(datas.orderRefundMaintain.warehouse_id==s.warehouseId){
                getGoodsAddress=s.provinceName+""+s.cityName+""+districtName
                addressDetail=s.detailAddress
                received_name=s.contactPerson
                received_telephone=s.contactPhone
            }
        })
    }else {
        $('#addressDetail').val(detailAddressName);
        $('#receiveArea').val(provinceName+cityName+areaName);
        $('#receiverName').val(receiverName);
        $('#receiverPhone').val(receiverPhone);
        $('#receiveArea').attr("disabled",false);
        $('#addressDetail').attr("disabled",false);
        $('#receiverName').attr("disabled",false);
        $('#receiverPhone').attr("disabled",false);
    }
    console.log(this.value);
})
/*订单备注编辑*/
var oldVal = "";

function toEdit() {
    oldVal = $("#remark").val();
    $("#isSaveFalse").css({
        display: "none"
    });
    $("#isSaveTrue").css({
        display: "block"
    });
    $("#remark").removeAttr("readonly");
}
function toCancle() {
    $("#remark").val(oldVal);
    $("#isSaveFalse").css({
        display: "block"
    });
    $("#isSaveTrue").css({
        display: "none"
    });
    $("#remark").attr("readonly","readonly");
}
function remarkToSave() {
    function btnDisplay() {
        $("#isSaveFalse").css({
            display: "block"
        });
        $("#isSaveTrue").css({
            display: "none"
        });
        $(".orderRemark textarea").attr("readonly","readonly");
    }
    btnDisplay()
    /*进行添加备注请求*/
    $.ajax({
        contentType:"application/json",
        type: "POST",
        url: root.orderInter.order_saveMaintainRemark,
        cache: false,  //禁用缓存
        dataType: "json",
        data: JSON.stringify({
            // "bus_id":$('#askFor-code').html(),
            "maintain_id":maintain_id,
            "operate_userid":loginData.user.user_ID,
            "operate_username":loginData.user.name,
            // "operate_type":10,
            "maintain_remark":$('#remark').val(),
        }),
        success: function (data) {
            console.log(data)
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(XMLHttpRequest);
        }
    });
}

/*详细信息编辑*/
function requireUpdataInter(updataData){
    $.ajax({
        contentType:"application/json",
        type: "POST",
        url: root.orderInter.order_edit,
        cache: false,  //禁用缓存
        dataType: "json",
        /*data: JSON.stringify({
            order_id:orderDetail.orderBase.order_id,
            order_status:orderDetail.orderBase.order_status,
            receiver_detail_address:"北京市海淀区大柳树北",
            received_name:"李晓艺",
            received_phone:18810919337,
            invoice_type:1,
            invoice_content:10,
            order_remark:"突然不想买了",
            wanna_arrived_in:"2018-11-11 10:10:10"
        }),*/
        data: updataData,
        success: function (result) {
            if(result.code == 0){
                $("#addressInpBox").css({
                    display: "none",
                })
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(XMLHttpRequest);
        }
    });
}
function updataDisplay(ids) {
    $(ids).css({
        display: "block",
    })
}
/*
function updataCancel() {
    $("#addressInpBox").css({
        display: "none",
    });

}*/


// 跳转商品详情页
function goToGoodsDetail(title,url,sku_Id) {
    var index = layer.open({
        type: 2,
        title: title,
        content: url +'?sku_Id='+sku_Id
    });
    layer.full(index);

}
//跳转订单详情页
function checkOrder(title,url){
    var orderid = $('#order-code').html();
    sessionStorage.setItem("orderId",orderid);
    var index = layer.open({
        type: 2,
        title: title,
        content: url
    });
    layer.full(index);
}